package com.dayangxiaoen.pms.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dayangxiaoen.pms.mapper.SalesVolumeMapper;
import com.dayangxiaoen.pms.po.ExchangeAmount;
import com.dayangxiaoen.pms.po.SalesVolume;
import com.dayangxiaoen.pms.service.SalesVolumeService;
import com.dayangxiaoen.pms.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDate;
import java.util.List;

/**
 * @author dayangxiaoen
 */

@Service
public class SalesVolumeImpl extends ServiceImpl<SalesVolumeMapper, SalesVolume> implements SalesVolumeService {

    @Autowired
    private SalesVolumeMapper salesVolumeMapper;

    @Override
    public Result findSalesVolumeTop20ByDays(int days) {
        LocalDate now = LocalDate.now();

        LambdaQueryWrapper<SalesVolume> wrapper = new LambdaQueryWrapper<SalesVolume>();
        wrapper.eq(SalesVolume::getDate,now);
        wrapper.eq(SalesVolume::getDays,days);

        List<SalesVolume> salesVolumes = salesVolumeMapper.selectList(wrapper);

        return Result.sucess(salesVolumes,"获取销售量成功");

    }



}
